<template>
  <view class="bgff pt20 pm20">
    <view class="pd">
      <textarea
        v-model="formData.note"
        placeholder="请输入审批意见"
        class="dfsrteeret"
      />
    </view>

    <view class="pl10">
      <view
        class="eerttser ml10 cz mt20 pr"
        v-for="(sd, idx) in formData.image"
        @tap="closweer(idx)"
      >
        <image :src="sd" class="fm"></image>
        <icon type="clear" color="red" class="dsfertxe"></icon>
      </view>

      <!-- <image
        src="../../../static/img/asddf.jpg"
        class="eerttser ml10 cz mt20"
        @tap="yjjhsd"
      ></image> -->
    </view>

    <view class="kjnmxeeretr fz32 row">
      <view class="col" @tap="shenbpi(1)">
        同意
      </view>
      <view class="col dsfsdft" @tap="shenbpi(2)">
        拒绝
      </view>
    </view>

    <uni-popup ref="popup" type="message">
      <uni-popup-message type="success" :message="message"></uni-popup-message>
    </uni-popup>
  </view>
</template>
<script>
export default {
  data() {
    return {
      message: "审核成功",
      formData: {
        note: "",
        result: "",
        applyFormId: "",
        // image: [],
      },
    };
  },
  mounted() {
    this.formData.applyFormId = this.pageQuery.applyFormId;
  },
  methods: {
    yjjhsd() {
      let that = this;
      uni.chooseImage({
        success: function (res) {
          res.tempFilePaths.map((a) => {
            that.formData.image.push(a);
          });
        },
      });
    },
    async shenbpi(result) {
      this.formData.result = result;
      let query = this.$mp ? this.$mp.page.options : this.$route.query
      if(query.fp == 'true' && result == 1) {
        // this.$refs.popup.open();
        // setTimeout(function() {
          uni.navigateTo({
            url: `/pages/gongzuo/guanli/fenIndex?startTime=${this.pageQuery.startTime}&endTime=${this.pageQuery.endTime}&note=${this.formData.note}&applyFormId=${this.pageQuery.applyFormId}`,
          });
        // },1500)
      } else {
        let res = await this.$api.applyCheck(this.formData);
        let that = this;
        this.$refs.popup.open();
        setTimeout(function() {
          uni.navigateTo({
            url: "/pages/gongzuo/shenhe/index",
          });
        },1500)
      }
    },
    closweer(e) {
      this.formData.image.splice(e, 1);
    },
  },
};
</script>
<style scoped>
.dfsrteeret {
  font-size: 30upx;
  width: 100%;
  border-radius: 8upx;
  height: 300upx;
  padding-top: 10upx;
}
.eerttser {
  width: 160upx;
  height: 160upx;
  display: inline-block;
}
.eerttser image.fm {
  width: 100%;
  height: 100%;
}
.dsfsdft {
  background: #10fc97;
}
.dsfertxe {
  position: absolute;
  right: -10upx;
  top: -10upx;
}
</style>
